import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import { resolve } from 'path'
import { viteMockServe } from 'vite-plugin-mock'
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()]
    }),
    Components({
      resolvers: [ElementPlusResolver()]
    }),
    viteMockServe({
      supportTs: true, // 如果你的 mock 文件使用了 TypeScript，请设置为 true
      mockPath: 'src/mock', // Mock 文件的目录
      localEnabled: true, //是否在开发阶段可使用
      prodEnabled: false //生产环境下为false，这样就不会被打包到生产包中
    })
  ],
  resolve: {
    alias: {
      '@': resolve(__dirname, './src')
    }
  },
  css: {
    // CSS 预处理器
    preprocessorOptions: {
      //define global scss variable
      scss: {
        javascriptEnabled: true, //开启sass
        additionalData: '@import "@/resource/style/global.scss";'
      }
    }
  }
})
